import { WeaPopoverHrm,WeaLocaleProvider,WeaTools } from 'ecCom';
import loadjs from 'loadjs';

class Home extends React.Component {
    componentDidMount(){
        const params = {};
        WeaTools.callApi('/api/workflow/injectDev/loadFileList', 'POST', params).then(data =>{
            const files = data.files;
            if(files && files.length > 0){
                const init = () => {
                    if(window.console)  console.log("加载二开注入JS文件成功", files);
                };
                loadjs.isDefined('customDev') ? loadjs.ready('customDev', init) : loadjs(files, 'customDev', init);
            }
        });
    }
    render() {
        const isSingle = window.location.pathname.indexOf('/spa/workflow/index') > -1;
        return (
            <div style={{height:"100%"}}>
                {isSingle && <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@wayz86`} />}
                <WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@2p09n7`}>
                {this.props.children}
                </WeaLocaleProvider>
            </div>
        )
    }
}

export default Home
